//
// Created by 乐亦聪 on 15/5/20.
//

#ifndef UNTITLED_INC_H
#define UNTITLED_INC_H

enum Direction {
    TOP = 0,
    DOWN = 1,
    LEFT = 2,
    RIGHT = 3,
    TOPLEFT = 4,
    TOPRIGHT = 5,
    DOWNLEFT = 6,
    DOWNRIGHT = 7,
    CENTER = 8
};

enum Faction {
    F1 = 1,
    F2 = 2,
    None = 0,
    BOTH = 3
};

typedef unsigned int Board[5];

struct Game {
    int spacer_s1 = 0;
    Board board;
    int spacer_s2 = 0;
    int records[640];
    int step = 0;
    int steps = 0;
    int action;
    int spacer_s3 = 0;
    Board capable;
    int spacer_s4 = 0;
    int f1 = 2;
    int f2 = 2;
    int c1 = 4;
    int c2 = 4;
    int capableCache[28];
    int (*players[2])(Board board, Faction f, int*);
};

int randomSelectBot(Board board, Faction f, int* cache);
int randomGameSelectorBot(Game game, Faction f, int*cache);
void printBoard(Board board);

int popcnt(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}

#endif //UNTITLED_INC_H
